﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CarolLib
{
    public static class FileOperationHelper
    {
        public static string read(string path)
        {
            FileStream fin;
            if (!File.Exists(path)) fin = File.Create(path);
            else fin = new FileStream(path, FileMode.Open, FileAccess.Read);
            StreamReader brin = new StreamReader(fin, Encoding.Default);
            string s = brin.ReadToEnd(); brin.Close(); return s;
        }
        //public static string oprater(string s) { return s = s + "\r\n" + textBox1.Text + "\r\n" + DateTime.Now.ToString(); }        

        public static void save(string s, string path)
        {
            FileStream fout = new FileStream(path, FileMode.Create, FileAccess.Write);
            StreamWriter brout = new StreamWriter(fout, Encoding.Default);
            brout.Write(s);
            brout.Close();
        }
    }
}
